package com.itheima.rxdemo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by TUTU on 2016-11-18.
 */
public class WeatherData1 extends WeatherData {
    private List<Observer> mObservers;

    private float temperature;//温度
    private float humidity;//湿度
    private float pressure;//气压
    private List<Float> forecastTemperatures;//未来几天的温度
    //构造方法 初始化观察者集合
    public WeatherData1(){
        mObservers = new ArrayList<Observer>();
    }
    public void measurementsChanged() {
        notifyObservers();
    }
    //设置一些温度,湿度,气压,未来的温度
    public void setMeasurements(float temperature, float humidity,
                                float pressure, List<Float> forecastTemperatures) {
        this.temperature = temperature;
        this.humidity = humidity;
        this.pressure = pressure;
        this.forecastTemperatures = forecastTemperatures;
        notifyObservers();
//        measurementsChanged();
    }

    public float getTemperature() {
        return temperature;
    }

    public float getHumidity() {
        return humidity;
    }

    public float getPressure() {
        return pressure;
    }

    public List<Float> getForecastTemperatures() {
        return forecastTemperatures;
    }

    @Override
    public void playGame() {

    }

    @Override
    public void registerObserver(Observer observer) {
        mObservers.add(observer);
    }

    @Override
    public void removeObserver(Observer observer) {
        mObservers.remove(observer);
    }

    @Override
    public void notifyObservers() {
        for (Observer observer : mObservers) {
            observer.update();
        }
    }
}
